//
//  RNOLBuyInvestViewController.m
//  RongNiuOnline
//
//  Created by apple on 2018/5/3.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLBuyInvestViewController.h"
#import "RNOLInvestMoneyFormView.h"
#import "RNOLSelectCouponControllerViewController.h"
#import "RNOLPresentAnimationTransition.h"


@interface RNOLBuyInvestViewController ()<RNOLInvestMoneyFormViewDelegate,UIViewControllerTransitioningDelegate>

@property (nonatomic,strong) RNOLPresentAnimationTransition *presentAnimation;
@property (nonatomic,strong) id obj;

@end

@implementation RNOLBuyInvestViewController

- (RNOLPresentAnimationTransition *)presentAnimation{
    if (!_presentAnimation) {
        _presentAnimation = [[RNOLPresentAnimationTransition alloc] init];
    }
    return _presentAnimation;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    [self setupNavBarTitleViewWithText:@"立即购买"];
    [self setup];
    
}

- (void)setup{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , KHIGHT-kNavBarHeight)];
    adjustsScrollViewInsets_NO(scrollView, self);
    scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview: scrollView];
    
    RNOLInvestMoneyFormView *formView = [RNOLInvestMoneyFormView FromXIB];
    formView.delegate = self;
    [scrollView addSubview: formView];
    scrollView.contentSize = CGSizeMake(KWIDTH, CGRectGetMaxY(formView.frame));
    
}


#pragma mark- <RNOLInvestMoneyFormViewDelegate>
//充值
- (void)rechargeActionWithMoney:(NSString *)money{
    
}

// 选择红包或者优惠券
- (void)selectCouponAction{
    RNOLSelectCouponControllerViewController *selectCouponVC = [RNOLSelectCouponControllerViewController new];
    selectCouponVC.transitioningDelegate = self;
    selectCouponVC.modalPresentationStyle = UIModalPresentationCustom;
    [self.navigationController presentViewController: selectCouponVC animated:YES completion:^{
        
    }];
    
    [[kNotificationCenter rac_addObserverForName:kUseRedBagOrCouponSelectedActionNotification object:nil] subscribeNext:^(NSNotification * note) {
        self.obj = note.object;
    }];
    
    [selectCouponVC setConfirmBlock:^{
        NSLog(@"%@",self.obj);
    }];
}


//全投
- (void)allDownOrderAction{
    
    
}


//立即购买
- (void)immediatelyBuyInvestAction{
    
    
}

#pragma mark - UIViewControllerTransitioningDelegate
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    return self.presentAnimation;
}


@end
